#!/bin/sh

# $Id$

cd "$(dirname "$0")"

. functions.sh

TEST_INIT $(basename "$0")

# Test that we pick the initial indentation correctly.

TEST <<"EOF"
one
  two
     three
---
one
two
three
EOF

TEST <<"EOF"
  one
two
     three
---
  one
  two
  three
EOF

# Test trimming of trailing white space.

TEST <<"EOF"
a
b 
c  
---
a
b
c
EOF

# Test indentation of lists.

TEST <<"EOF"
(one
  two
     three)
(one two
three
four)
(one two three
four)
(
one two
three
four)
(one
(a b
c d)
two three
four)
(one (a b
c d)
two three
four)
---
(one
 two
 three)
(one two
     three
     four)
(one two three
     four)
(
 one two
 three
 four)
(one
 (a b
    c d)
 two three
 four)
(one (a b
        c d)
     two three
     four)
EOF

TEST <<"EOF"
'(a b 
c d)
`(a b 
c d)
---
'(a b
  c d)
`(a b
  c d)
EOF

TEST <<"EOF"
(1 2 
3 4)
("one" 2 
3 4)
(#t 2 
3 4)
---
(1 2
 3 4)
("one" 2
 3 4)
(#t 2
 3 4)
EOF

TEST <<"EOF"
((a) b
c d)
('a b
c d)
(`a b
c d)
(,a b
c d)
(,@a b
c d)
(#; a b
c d)
---
((a) b
 c d)
('a b
 c d)
(`a b
 c d)
(,a b
 c d)
(,@a b
 c d)
(#; a b
 c d)
EOF
 
TEST <<"EOF"
(let ((a b))
c
d)
(let
((a b))
c d)
(let
((a b)
(c d))
e
f)
(let ((a b)) c d
e f)
(do ((a 1 (+ a 1))) ((= a 5)) 
b)
(do ((a 1 (+ a 1))) 
((= a 5)) 
b)
(do 
((a 1 (+ a 1))) 
((= a 5)) 
b)
---
(let ((a b))
  c
  d)
(let
    ((a b))
  c d)
(let
    ((a b)
     (c d))
  e
  f)
(let ((a b)) c d
  e f)
(do ((a 1 (+ a 1))) ((= a 5))
  b)
(do ((a 1 (+ a 1)))
    ((= a 5))
  b)
(do
    ((a 1 (+ a 1)))
    ((= a 5))
  b)
EOF

